package task06_06;

import java.util.ArrayList;

public class UserDaoList implements  UserDao {
    ArrayList<User> userArrayList =new ArrayList<User>();
    @Override
    public void register(User user) {
        userArrayList.add(user);
    }

    @Override
    public boolean login(String name, String password) {
        for (int i = 0; i <userArrayList.size(); i++) {
            if(userArrayList.get(i).getName().equals(name)&&
                    userArrayList.get(i).getPassword().equals(password)){
                return true;
            }
        }
        return false;
    }

    @Override
    public void show() {
        for (User user:userArrayList){
            System.out.println(user.getName()+":"+user.getPassword());
        }
    }
}
